
<meta charset="UTF-8">
<script type="text/javascript">
	$(function(){
		$('#xsClasstb').combobox({
			onSelect:function(e){
				var bjId3=e.id;
				$('#xsClassst').combobox({
					url:'xuesheng/list?bjId='+bjId3,
				})
				$('#xsClassGradeDiv').hide();
				$('#xsClassst').combobox('enable');
			}
		})

		$('#xsClassGradebtn').bind('click',function(){
			var bjId3=$('#xsClasstb').combobox('getValue');
			var xsId=$('#xsClassst').combobox('getValue');
			if(xsId==0){
				$('#xsClassGradeDiv').hide();
			}else{
				$('#xsClassGradeDiv').show();
				shuaxin2(bjId3,xsId);
				$('#xsClassGradeTable').datagrid('clearSelections');
			}
		})	
	})
	
	function shuaxin2(bjId3,xsId){
	$('#xsClassGradeTable').datagrid($.extend({},$.crudgrid.defaults,{
		url:'grade/page2?bjId='+bjId3+"&xsId="+xsId,
		onLoadSuccess:function(data){
	            $("input[name='ipt2']").numberbox({
	            	onChange:function(grade,oldgrade){
		            	var grid=$('#xsClassGradeTable').datagrid('getSelected');
						xg(grid.id,grade);
		            }
		        });  
	   	},
		columns:[
			[
				{title:'课程',field:'course',width:200,formatter:function(value,row,index){
	            		return row.course.name;
					}
	           	},
				{title:'成绩',field:'grade',width:200,formatter:function(value,row,index){
						if(!row.grade){
							row.grade=0;
						}
					   return '<input  name="ipt2" value="'+row.grade+'">'
					}
				},
			]		
		],
		toolbar:['-',$.crudgrid.buttons.refrsh,'-']
	}))
}

$("input[name='ipt2']").numberbox({
	    min:0,
	    precision:0
});
	 
function xg(id,grade){
		if(!(/^[0-9]\d*$/.test(grade))){
			$.messager.alert('提示','请输入正整数','info');
			return;
		};
	$.post('grade/classCjxg',{id:id,grade:grade},function(data){
		if(data.success){
			$.messager.show({title:'提示',msg:data.msg});
		}else{
			$.messager.alert('提示',data.msg,'warning');
		}
	});
}
	
</script>

<div class="easyui-panel" data-options="fit:true" title="个人成绩查询" style="display: flex;flex-direction: column;">
<p style="flex-grow: 0;">
	<span style="margin-left:10px ">选择班级：</span><select id="xsClasstb"class="easyui-combobox" data-options="
		editable:false,
		width:200,
		url:'tbclass/list',
		valueField:'id',
		panelHeight:200,
		textField:'name',
		icons: [{
			iconCls:'icon-clear',
       		handler: function(e){
        		$(e.data.target).textbox('clear');
        		$('#xsClassGradeDiv').hide();
        		$('#xsClassst').combobox('clear')	
        		$('#xsClassst').combobox('disable')	
    			}
    		}]
	"></select>
	<span style="margin-left:10px ">选择学生：</span><select id="xsClassst"class="easyui-combobox" data-options="
		editable:false,
		width:200,
		disabled:true,
		valueField:'id',
		panelHeight:200,
		textField:'name',
		icons: [{
			iconCls:'icon-clear',
       		handler: function(e){
        		$(e.data.target).textbox('clear');
        		$('#xsClassGradeDiv').hide();
    			}
    		}]
	"></select>
	<a id="xsClassGradebtn"  class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="margin-left: 10px">查询</a>
</p>
<div id="xsClassGradeDiv" style="flex-grow: 1;"> 
	<table id="xsClassGradeTable"></table>
</div>
</div>
